package com.changgou.web.gateway.filter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author: HuangFu
 * @Date: 2020/2/15 19:19
 * @Description:
 */
@Component
public class UrlFilter {

    @Value("${system.filterPath}")
    private String filterPath;

    /**
     * 校验地址 true需要令牌 ，false不需要令牌
     * @param url
     * @return
     */
    public boolean hasAuthorize(String url){
        String[] filters = filterPath.replace("**", "").split(",");
        for (String filter : filters) {
            if(url.startsWith(filter)){
                return true;
            }
        }
        return false;
    }
}
